const now = new Date();
console.log(now); // 输出当前⽇期和时间

function Rectangle(name, width, height) {
    this.name = name; // 分配name属性
    this.width = width; // 分配width属性
    this.height = height; // 分配height属性
}

//const rect1 = new Rectangle("矩形 1", 10, 10);
//console.log(rect1);
// 输出：Rectangle { name: '矩形 1', width: 10, height: 10 }
//const rect2 = Rectangle("矩形 2", 20, 20);
//console.log(rect2); // 输出：undefined

function Rectangle(name, width, height) {
    this.name = name;
    this.width = width;
    this.height = height;
    this.area = function () {
        return this.width * this.height;
    };
}

const rect1 = new Rectangle("矩形 1", 10, 10);
console.log(rect1.area()); // 输出：100

const rect2 = new Rectangle("矩形 2", 20, 10);
const rect3 = new Rectangle("矩形 3", 30, 30);
console.log(rect2.name); // 输出：矩形 2
console.log(rect3.area()); // 输出：900

console.log(rect1.constructor);
// 输出：[Function: Rectangle]

console.log(rect2 instanceof Rectangle); // 输出：true
console.log(rect3 instanceof Date); // 输出：false